SearchForSubsequence Generic Method

Wintellect PowerCollections

Collapse imageExpand ImageCollapseAll imageExpandAll imageDropDown imageDropDownHover imageCopy imageCopyHover image
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Searchs a list for a sub-sequence of items that match a particular pattern. A subsequence of list matches pattern at index i if list[i] is "equal" to the first item in pattern, list[i+1] is "equal" to the second item in pattern, and so forth for all the items in pattern. The passed BinaryPredicate is used to determine if two items are "equal".

Namespace: Wintellect.PowerCollections
Assembly:  PowerCollections (in PowerCollections.dll)

Syntax

C#
public static int SearchForSubsequence<T>(
	IList<T> list,
	IEnumerable<T> pattern,
	BinaryPredicate<T> predicate
)
Visual Basic (Declaration)
Public Shared Function SearchForSubsequence(Of T) ( _
	list As IList(Of T), _
	pattern As IEnumerable(Of T), _
	predicate As BinaryPredicate(Of T) _
) As Integer
Visual C++
public:
generic<typename T>
static int SearchForSubsequence (
	IList<T>^ list, 
	IEnumerable<T>^ pattern, 
	BinaryPredicate<T>^ predicate
)

Parameters

list
IList<(Of <T>)>
The list to search.
pattern
IEnumerable<(Of <T>)>
The sequence of items to search for.
predicate
BinaryPredicate<(Of <T>)>
The BinaryPredicate used to compare items for "equality".

Return Value

The first index with list that matches the items in pattern.

Type Parameters

T
The type of items in the list.

Remarks

Since an arbitrary BinaryPredicate is passed to this function, what is being tested for in the pattern need not be equality.

See Also